package name.huzhenbo.java.algorithm.talent;

class HanoiTower {
    private int numOfStories;

    public HanoiTower(int numOfStories) {
        this.numOfStories = numOfStories;
    }

    public void move() {
        _move(numOfStories, 'x', 'y', 'z');
    }

    private void _move(int numOfStories, char x, char y, char z) {
        if(numOfStories == 1){
            doMove(1, x, z);
        }else{
            _move(numOfStories - 1, x, z, y);
            doMove(numOfStories, x, z); 
            _move(numOfStories - 1, y, x, z);
        }
    }

    private void doMove(int floor, char x, char z) {
        System.out.println("move floor " + new Integer(floor) + " from " + x + " to " + z);
    }
}
